﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;
using DAL;
namespace PhongMachTu.GUI
{
    public partial class frmThanhToan : Form
    {
 
        public frmThanhToan()
        {
            InitializeComponent();
        }       
        private void frmThanhToan_Load(object sender, EventArgs e)
        {
            txtTienThuoc.Text = MsgBox.hd.TienThuoc.ToString();
            txtTienKham.Text = MsgBox.hd.TienKham.ToString();
            txtTongTien.Text = MsgBox.hd.TongTien.ToString();
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            HoaDon hd = new HoaDon();
            HoaDonBLL bllHoaDon = new HoaDonBLL();
            hd.MaBenhNhan = MsgBox.hd.MaBenhNhan;
            hd.MaBenhNhan = MsgBox.hd.MaBenhNhan;
            hd.NgayKham = DateTime.Now;
            hd.TienKham = MsgBox.hd.TienKham;
            hd.TienThuoc = MsgBox.hd.TienThuoc;
            hd.TongTien = MsgBox.hd.TongTien;
            if (bllHoaDon.ThemHoaDon(hd))
            {
                MsgBox.Success("Lưu hoá đơn thành công !");
                this.Close();
            }
            else
            {
                MsgBox.Success("Lưu hoá đơn thất bại !");
            }
        }
        public event EventHandler Button_Clicked;
        private void btnLuuVaIn_Click(object sender, EventArgs e)
        {
            HoaDon hd = new HoaDon();
            HoaDonBLL bllHoaDon = new HoaDonBLL();
            hd.MaKhamBenh = MsgBox.hd.MaKhamBenh;
            hd.MaBenhNhan = MsgBox.hd.MaBenhNhan;
            hd.NgayKham = DateTime.Now;
            hd.TienKham = MsgBox.hd.TienKham;
            hd.TienThuoc = MsgBox.hd.TienThuoc;
            hd.TongTien = MsgBox.hd.TongTien;
            if (bllHoaDon.ThemHoaDon(hd))
            {
                MsgBox.Success("Lưu hoá đơn thành công !");
                if (this.Button_Clicked != null)
                    this.Button_Clicked(sender, e);
                this.Close();
              
            }
            else
            {
                MsgBox.Success("Lưu hoá đơn thất bại !");
            }
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
